package com.taotao.common.service;

import org.springframework.beans.factory.annotation.Autowired;
import redis.clients.jedis.JedisCluster;

public class RedisClusterServiceImpl implements RedisService {
    @Autowired(required = false)
    private JedisCluster jedisCluster;

    /**
     * 设置值
     */
    @Override
    public String set(String key, String value) {
        return jedisCluster.set(key, value);
    }

    /**
     * 设置值并同时设置过期时间
     */
    @Override
    public String setex(String key, int seconds, String value) {
        return jedisCluster.setex(key, seconds,value);
    }

    /**
     * 设置key过期
     */
    @Override
    public Long expire(String key, int seconds) {
        return jedisCluster.expire(key, seconds);
    }

    /**
     * 获取key值
     */
    @Override
    public String get(String key) {
        return jedisCluster.get(key);
    }

    /**
     * 删除key值
     */
    @Override
    public Long del(String key) {
        return jedisCluster.del(key);
    }

    /**
     * 自増
     */
    @Override
    public Long incr(String key) {
        return jedisCluster.incr(key);
    }
}
